package com.taotao.rest.service.ipml;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import com.taotao.common.pojo.TaotaoResult;
import com.taotao.common.utils.ExceptionUtil;
import com.taotao.rest.dao.IJedisClient;
import com.taotao.rest.service.IRedisSyncService;

/**
 * 使redis中的内容和数据库中的内容进行同步
 * 
 * @author Administrator
 *
 */
@Service
public class RedisSyncServiceIpml implements IRedisSyncService {
	@Autowired
	private IJedisClient jedisClient;

	@Value(value = "${INDEX_CONTENT_REDIS_KEY}")
	private String INDEX_CONTENT_REDIS_KEY;

	@Value(value = "${INDEX_ITEM_CAT_REDIS_KEY}")
	private String INDEX_ITEM_CAT_REDIS_KEY;

	/**
	 * 对首页大广告内容进行同步
	 */
	@Override
	public TaotaoResult syncContent(Integer category_id) {
		try {
			this.jedisClient.hdel(INDEX_CONTENT_REDIS_KEY, category_id + "");
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return TaotaoResult.build(500, ExceptionUtil.getStackTrace(e));
		}
		return TaotaoResult.ok();
	}

	// @Override
	// public TaotaoResult syncItemCat(String key) {
	// // TODO Auto-generated method stub
	// try {
	// this.jedisClient.hdel(INDEX_ITEM_CAT_REDIS_KEY, key);
	// } catch (Exception e) {
	// // TODO Auto-generated catch block
	// e.printStackTrace();
	// return TaotaoResult.build(500, ExceptionUtil.getStackTrace(e));
	// }
	// return TaotaoResult.ok();
	// }
}
